//
//  SecondTableViewCell.m
//  MarianasTrench
//
//  Created by wangjue on 16/3/18.
//  Copyright © 2016年 王爵. All rights reserved.
//

#import "SecondTableViewCell.h"

@interface SecondTableViewCell ()
@property (nonatomic, retain) UIImageView *leftImage;
@property (nonatomic, retain) UILabel *rightUpLabel;
@property (nonatomic, retain) UILabel *rightCenterLabel;
@property (nonatomic, retain) UILabel *rightDownLabel;
@property (nonatomic, retain) UIView *lineView;

@end

@implementation SecondTableViewCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubViews];
    }
    return self;
}


-(void)createSubViews{
    self.leftImage = [[UIImageView alloc] init];
    [self.contentView addSubview:_leftImage];
    
    self.rightUpLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_rightUpLabel];
    
    self.rightDownLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_rightDownLabel];
    
    self.rightCenterLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_rightCenterLabel];
    
    self.lineView = [[UIView alloc] init];
    [self.contentView addSubview:_lineView];
}


-(void)layoutSubviews{
    [super layoutSubviews];
    
    _leftImage.frame = CGRectMake(10, 20, self.contentView.frame.size.width / 4, 100);
    _leftImage.layer.borderWidth = 1;
    
    _rightUpLabel.frame = CGRectMake(20 + self.contentView.frame.size.width / 4 , 20, self.contentView.frame.size.width / 2, 20);
    
    _rightCenterLabel.frame = CGRectMake(_rightUpLabel.frame.origin.x, 50, self.contentView.frame.size.width / 1.5, 20);
    _rightCenterLabel.textColor = [UIColor grayColor];
    _rightCenterLabel.font = [UIFont systemFontOfSize:15];
    
    _rightDownLabel.frame = CGRectMake(_rightUpLabel.frame.origin.x, 80, 100, 16);
    _rightDownLabel.font = [UIFont systemFontOfSize:15];
    _rightDownLabel.textColor = [UIColor grayColor];
    
    _lineView.frame = CGRectMake(0, self.contentView.frame.origin.y, self.contentView.frame.size.width, 1);
    _lineView.backgroundColor = [UIColor grayColor];
    
}


-(void)setModel:(ListenModel *)model{
    _model = model;
    
    [_leftImage sd_setImageWithURL:[NSURL URLWithString:_model.coverMiddle] placeholderImage:[UIImage imageNamed:@"no_network@3x"]];
    
    _rightUpLabel.text = _model.title;
    
    _rightCenterLabel.text = _model.intro;
    
    _rightDownLabel.text = [NSString stringWithFormat:@"%@集", _model.tracks];
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
